Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 6, 2026

The MCP server's update tool was spawning gh-aw as a subprocess for each invocation. This refactoring replaces subprocess execution with direct function calls.

Changes

  • New context-aware API: Added UpdateWorkflowsWithExtensionCheckContext(ctx context.Context, output io.Writer, ...) that:

    • Respects context cancellation at each major step
    • Captures output to provided io.Writer instead of os.Stderr
    • Returns captured output string alongside error for MCP responses
  • WithWriter helper functions: Created output-parameterized versions of internal helpers:

    • checkExtensionUpdateWithWriter
    • UpdateActionsWithWriter
    • UpdateWorkflowsWithWriter
    • RunFixWithWriter / runFixCommandWithWriter
    • createUpdatePRWithWriter
    • showUpdateSummaryWithWriter
    • processWorkflowFileWithInfo(w io.Writer, ...)
  • MCP server integration: Updated mcp_server.go update tool handler to call UpdateWorkflowsWithExtensionCheckContext directly with bytes.Buffer for output capture

  • Backward compatibility: Existing public functions unchanged, delegate to new WithWriter versions using os.Stderr

Example

Before:

// MCP server spawned subprocess
cmd := execCmd(ctx, "update", "--major", "--force")
output, err := cmd.CombinedOutput()

After:

// Direct function call with context and output capture
var buf bytes.Buffer
outputStr, err := UpdateWorkflowsWithExtensionCheckContext(
    ctx, &buf, workflowNames, allowMajor, force, ...)

No global state introduced. All state passed through parameters for thread-safe concurrent usage.

Original prompt

Refactor the MCP-server command implementation of the "update" tool to call the Go function command directly instead of executing the gh-aw binary.

Do not add global state, pass context as variable if needed. Assume concurrent usage.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 6, 2026 13:46
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
… issues

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor MCP-server update tool to call Go function directly Refactor MCP server update tool to call Go function directly Feb 6, 2026
Copilot AI requested a review from pelikhan February 6, 2026 13:54
@pelikhan pelikhan closed this Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants